//
//  TipsTableViewCell.swift
//  Pods
//
//  Created by eme on 2017/4/7.
//
//

import UIKit
import RickonCore

class TipsTableViewCell: UITableViewCell {
    
    @IBOutlet weak var tips_TextView: UITextView!

    @IBOutlet weak var lineView: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        tips_TextView.layer.borderColor = UIColor(hex: "979797").cgColor
        tips_TextView.layer.borderWidth = 0.5
        lineView.backgroundColor = Theme.v.separate_Line
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
extension EvaluationVc:UITextViewDelegate{
    func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
        
        if textView.textColor != UIColor.black
        {
            textView.text = ""
            textView.textColor = UIColor.black
            return true
        }
        else
        {
            if textView.text == "快来分享你的购买心得!"{
                
                self.modelArr[textView.tag].customText = ""
                
            }else{
                
                self.modelArr[textView.tag].customText = textView.text
            }
            return true
        }
    }
    func textViewDidEndEditing(_ textView: UITextView) {
        
        if textView.text == "快来分享你的购买心得!"{
            
            self.modelArr[textView.tag].customText = ""
            
        }else{
            
            self.modelArr[textView.tag].customText = textView.text
        }
        if textView.text != ""
        {
            if ischange(text:textView.text,length: 150) != true
            {
//                self.view.makeEmeToast("最多输入150个字符")
            }
        }
        if textView.text == ""
        {
            textView.text = "快来分享你的购买心得吧!"
            textView.textColor = UIColor(hex: "c7c7cd")
        }
        
    }
    func ischange(text:String,length:Int) -> Bool
    {
        let num:NSInteger = (text as NSString).length
        
        if num > length
        {
            return false
            
        }
        else
        {
            return true
        }
    }
}
